module.exports = class extends think.Model {
  // eslint-disable-next-line camelcase
  async save({ wiki_id, ...form }) {
    if (form.nodeList) form.node_list = JSON.stringify(form.nodeList);
    // eslint-disable-next-line camelcase
    if (await this.where({ wiki_id }).count()) {
      // eslint-disable-next-line no-return-await
      return await this.where({ wiki_id }).update({
        ...form
      });
    } else {
      // eslint-disable-next-line no-return-await
      return await this.add({
        wiki_id,
        ...form
      });
    }
  }
};
